//
//  ByCellMemberListInfo.m
//  mijifen_ios
//
//  Created by mc on 2017/11/13.
//  Copyright © 2017年 itboye. All rights reserved.
//

#import "ByCellMemberListInfo.h"

@implementation ByCellMemberListInfo
{
    UIView      *_bgView;
    UILabel     *_phoneLabel;
    UILabel     *_priceLabel;
    UILabel     *_consumeLabel;
}

+ (instancetype)cellWithTableView:(UITableView*)tableView{
    
    static NSString *cellIdentifier = @"ByCellMemberListInfo";
    ByCellMemberListInfo *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = [[self alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
    return cell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSeparatorStyleNone;
        [self createViews];
    }
    return self;
}

- (void)createViews{
    _bgView = [[UIView alloc] init];
    [self addSubview:_bgView];
    [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(0));
        make.top.equalTo(@(0));
        make.right.equalTo(@(0));
        make.bottom.equalTo(@(0));
    }];
    
    _phoneLabel = [[UILabel alloc] init];
    [_bgView addSubview:_phoneLabel];
    CGFloat width = (SCREEN_WIDTH - 15 * 2) / 3;
    [_phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(0));
        make.top.equalTo(@(10));
        make.size.mas_equalTo(CGSizeMake(width, 30));
    }];
    _phoneLabel.textAlignment = NSTextAlignmentCenter;
    _phoneLabel.font = FONT(16);
    _phoneLabel.adjustsFontSizeToFitWidth = YES;
    
    _priceLabel = [[UILabel alloc] init];
    [_bgView addSubview:_priceLabel];
    [_priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_phoneLabel.mas_right);
        make.top.equalTo(@(10));
        make.size.mas_equalTo(CGSizeMake(width, 30));
    }];
    _priceLabel.font = FONT(16);
    _priceLabel.textAlignment = NSTextAlignmentCenter;
    _priceLabel.adjustsFontSizeToFitWidth = YES;
    
    _consumeLabel = [[UILabel alloc] init];
    [_bgView addSubview:_consumeLabel];
    [_consumeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_priceLabel.mas_right);
        make.top.equalTo(@(10));
        make.size.mas_equalTo(CGSizeMake(width, 30));
    }];
    _consumeLabel.font = FONT(16);
    _consumeLabel.textAlignment = NSTextAlignmentCenter;
    _consumeLabel.adjustsFontSizeToFitWidth = YES;
}

- (void)setModel:(ByModelAimMember *)model{
    _model = model;
    // 测试数据
    _phoneLabel.text = _model.phone;
    _priceLabel.text = _model.price;
    _consumeLabel.text = _model.cosume;
    
}

- (void)setIsSelected:(BOOL)isSelected{
    _isSelected = isSelected;
    if (_isSelected) {
        _bgView.layer.borderColor = BY_TEXT_COLOR.CGColor;
        _bgView.layer.borderWidth = 1;
    }else{
        _bgView.layer.borderColor = [UIColor lightGrayColor].CGColor;
        _bgView.layer.borderWidth = 0;
    }
}


@end
